﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Common;

public partial class Admin_Ajax_UploadPdfOrSwf : AdminPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string subPath = string.Empty;
        string typeModel = "userManual";
        string[] filetype = { ".pdf" };
        string typeStr = "pdf";
        if (RequestHelper.GetString("typeMode") == "flash")
        {
            filetype = new string[] { ".flv" };
            typeModel = "flash";
            typeStr = "flash";
        }
        HttpPostedFile jpeg_image_upload = Request.Files["Filedata"];
        int imgWidth;
        int imgHeight;
        string fullPath = Common.FileUploadHelper.BuildSavePath(jpeg_image_upload, System.Configuration.ConfigurationManager.AppSettings["ImagePath"], typeModel, out subPath,"");
        string mapPaht = Server.MapPath("~" + Path.GetDirectoryName(fullPath) + "/");
        Common.Enums.FileUploadResult result = Common.FileUploadHelper.FileUpload(jpeg_image_upload, mapPaht, Path.GetFileName(fullPath), 5242880 * 4, filetype, "", out imgWidth, out imgHeight);
        if (result == Common.Enums.FileUploadResult.文件上传成功)
        {
            subPath = ResolveUrl("~" + fullPath.ToLower().Replace("\\", "/").Replace("/websites", ""));
        }
        Response.Write("{\"typeModel\":\"" + typeStr + "\",\"url\":\"" + subPath + "\"}");
        Response.End();
    }
}

